package org.shj.spark.sql

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.sql.SparkSession

object DatasetTest {
  def main(args: Array[String]): Unit = {
        
    val ss = SparkSession.builder().appName("DatasetTest").master("local").getOrCreate();
    ss.sparkContext.setLogLevel("WARN")
    
    val ds = ss.read.json("E:/workspace/scala/sparkjava/src/main/resources/students.txt")
    ds.orderBy("age").show()    
    println("==============")
    
    ds.printSchema()
    println("==============")
    
    ds.select("name").show()
    println("==============")
    
    
    ds.createOrReplaceTempView("students");
    
    ss.sql("select * from students where age > 15").collect().foreach(println)
    
    
    ss.stop();
    
    
  }
}